package com.example.myapplication;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

public class zzzzz2025103101MainActivity extends AppCompatActivity implements View.OnClickListener{
    private FragmentManager fragmentManager;
    private FragmentTransaction fragmentTransaction;
    private TextView tv_recommend, tv_must_buy;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.zzzzz2025103101activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.zzzzz2025103101main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        init();
    }
    public void init() {
        tv_recommend = findViewById(R.id.zzzzz2025103101menu1);
        tv_must_buy = findViewById(R.id.zzzzz2025103101menu2);
        tv_recommend.setOnClickListener(this);
        tv_must_buy.setOnClickListener(this);
        fragmentManager = getSupportFragmentManager();
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.zzzzz2025103101content, new zzzzz2025103101RecommendFragment());
        fragmentTransaction.commit();
    }
    @Override
    public void onClick(View v) {
        fragmentTransaction = fragmentManager.beginTransaction();
        if(v.getId() == R.id.zzzzz2025103101menu1){
            tv_recommend.setBackgroundColor(Color.WHITE);
            tv_must_buy.setBackgroundResource(R.color.gray);
            fragmentTransaction.replace(R.id.zzzzz2025103101content, new zzzzz2025103101MustBuyFragment());
        }
        else if(v.getId() == R.id.zzzzz2025103101menu2){
            tv_recommend.setBackgroundResource(R.color.gray);
            tv_must_buy.setBackgroundColor(Color.WHITE);
            fragmentTransaction.replace(R.id.zzzzz2025103101content, new zzzzz2025103101RecommendFragment());
        }
        fragmentTransaction.commit();
    }
}